package com.example.springboot1.utils;

/**
 * @author ckj
 * @description TODO
 * @date 2023-09-12 9:17
 */


import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

public class ConditionProcessor {

    private Map<String, Function<String, BigDecimal>> conditionMap;

    public ConditionProcessor() {
        conditionMap = new HashMap<>();
        conditionMap.put("1", this::handleCondition1);
        conditionMap.put("2", this::handleCondition2);
        conditionMap.put("3", this::handleCondition3);
    }

    public BigDecimal process(String condition, String input) {
        Function<String, BigDecimal> handler = conditionMap.get(condition);
        if (handler != null) {
            return handler.apply(input);
        }

        return null;
    }

    public static void main(String[] args) {
        ConditionProcessor np = new ConditionProcessor();
        BigDecimal process = np.process("1", "2");
        System.out.println(process);
        int a=6;
        int b=7;
        int c=5;
        int d=6;
       boolean e= a<d;
       boolean f=b>c;
        System.out.println();
    }


    private BigDecimal handleCondition1(String input) {
        // 处理逻辑1
        return BigDecimal.valueOf(1);
    }

    private BigDecimal handleCondition2(String input) {
        // 处理逻辑2
        return BigDecimal.valueOf(2);
    }

    private BigDecimal handleCondition3(String input) {
        // 处理逻辑3
        return BigDecimal.valueOf(3);
    }
}
